From: Ian.Campbell@xensource.com Date: Mon, 22 May 2006 08:22:18 +0000 (+0100) Subject: New memory_op subops which return the apparent or actual physical address map. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16047^2~7 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=a141304c8e9f3e8f2702d3af54c790a6603e2bcb;p=xen.git New memory_op subops which return the apparent or actual physical address map. The new subops return a memory map in e820 format. This will allow the removal of some Xen special casing in the Linux port by using the same code as native. Signed-off-by: Ian Campbell --- diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 7e78e680e7..e614f3dc74 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2811,6 +2811,8 @@ long do_update_descriptor(u64 pa, u64 desc) return ret; } +typedef struct e820entry e820entry_t; +DEFINE_XEN_GUEST_HANDLE(e820entry_t); long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) { @@ -2869,6 +2871,39 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) break; } + case XENMEM_memory_map: + { + return -ENOSYS; + } + + case XENMEM_machine_memory_map: + { + struct xen_memory_map memmap; + XEN_GUEST_HANDLE(e820entry_t) buffer; + int count; + + if ( !IS_PRIV(current->domain) ) + return -EINVAL; + + if ( copy_from_guest(&memmap, arg, 1) ) + return -EFAULT; + if ( memmap.nr_entries < e820.nr_map + 1 ) + return -EINVAL; + + buffer = guest_handle_cast(memmap.buffer, e820entry_t); + + count = min((unsigned int)e820.nr_map, memmap.nr_entries); + if ( copy_to_guest(buffer, &e820.map[0], count) < 0 ) + return -EFAULT; + + memmap.nr_entries = count; + + if ( copy_to_guest(arg, &memmap, 1) ) + return -EFAULT; + + return 0; + } + default: return subarch_memory_op(op, arg); } diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 75818c53b6..bd2e265a5a 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -146,6 +146,34 @@ struct xen_translate_gpfn_list { typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t; DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t); +/* + * Returns the pseudo-physical memory map as it was when the domain + * was started. + */ +#define XENMEM_memory_map 9 +struct xen_memory_map { + /* + * On call the number of entries which can be stored in buffer. On + * return the number of entries which have been stored in + * buffer. + */ + unsigned int nr_entries; + + /* + * Entries in the buffer are in the same format as returned by the + * BIOS INT 0x15 EAX=0xE820 call. + */ + XEN_GUEST_HANDLE(void) buffer; +}; +typedef struct xen_memory_map xen_memory_map_t; +DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t); + +/* + * Returns the real physical memory map. Passes the same structure as + * XENMEM_memory_map. + */ +#define XENMEM_machine_memory_map 10 + #endif /* __XEN_PUBLIC_MEMORY_H__ */ /*